﻿using System;
using System.Drawing;

namespace MarioMapEditor
{
    class ObBlackground : ObObject
    {
        public enum INFO
        {
            S10 = 85, S20, S40, S80
        };

        public ObBlackground()
        {
            Width       = 1;
            Height      = 1;
        }

        public ObBlackground(INFO nID)
        {
            ID          = (int)nID;
            switch (nID)
            {
                case INFO.S10:
                    Width   = 10;
                    Height  = 10;
                    break;
                case INFO.S20:
                    Width   = 20;
                    Height  = 20;
                    break;
                case INFO.S40:
                    Width   = 40;
                    Height  = 40;
                    break;
                case INFO.S80:
                    Width   = 80;
                    Height  = 80;
                    break;
                default:
                    Width   = 10;
                    Height  = 10;
                    break;
            }
        }

        public override bool SetID(int nID)
        {
            if (checkType(nID))
            {
                ID = nID;
                switch (nID)
                {
                    case (int)INFO.S10:
                        Width = 10;
                        Height = 10;
                        break;
                    case (int)INFO.S20:
                        Width = 20;
                        Height = 20;
                        break;
                    case (int)INFO.S40:
                        Width = 40;
                        Height = 40;
                        break;
                    case (int)INFO.S80:
                        Width = 80;
                        Height = 80;
                        break;
                    default:
                        Width = 10;
                        Height = 10;
                        break;
                }
                return true;
            }
            return false;
        }

        public static bool checkType(int objectID)
        {
            if (Enum.IsDefined(typeof(INFO), objectID))
            {
                return true;
            }
            return false;
        }

        public override Bitmap GetBitmap()
        {
            if (!ObBlackground.checkType(ID))
            {
                return null;
            }
            var src = Properties.Resources.Blackground;
            return MainForm.ResizeImage(src, new Size(Width * MainForm.TileSize, Height * MainForm.TileSize));
        }
    }
}
